# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Joris Steyn <jorissteyn@gmail.com>
# Contributor: fnord0 <fnord0 AT riseup DOT net>

pkgname=zaproxy
pkgver=2.14.0
pkgrel=1
pkgdesc='Integrated penetration testing tool for finding vulnerabilities in web applications'
url='https://www.owasp.org/index.php/ZAP'
arch=('any')
license=('Apache')
depends=('bash' 'java-runtime' 'ttf-font')
_java=11
makedepends=('gradle' "java-environment=${_java}")
source=(${pkgname}-${pkgver}.tar.gz::"https://github.com/zaproxy/zaproxy/archive/v${pkgver}.tar.gz")
sha512sums=('660bb3b8f4789a2ae76c040ae879136da294f189bb331abc5f1e249a7fe69b64433c8a3e66d56d4f4d41072b20963afaa5615d76df5ade4049ea9d592faf017b')
b2sums=('ff0879be51575b24d83516b56cc145396bea5f753ae39931cad36f76ffab7933d383152d1e517057a95c84d12d7e58f0e29b4eb852d75c6af7dc8b140db8c3ad')

prepare() {
  cd ${pkgname}-${pkgver}
  cat > ${pkgname} <<EOF
#!/bin/sh
cd /usr/share/zaproxy
./zap.sh
cd -
EOF
}

build() {
  cd ${pkgname}-${pkgver}
  export PATH="/usr/lib/jvm/java-${_java}-openjdk/bin:$PATH"
  export JAVA_HOME="/usr/lib/jvm/java-${_java}-openjdk"
  /usr/bin/gradle :zap:distLinux
}

package() {
  cd ${pkgname}-${pkgver}
  install -d "${pkgdir}/usr/share/${pkgname}"
  tar zxf zap/build/distributions/ZAP_${pkgver}_Linux.tar.gz
  cp -pR ZAP_${pkgver}/. "${pkgdir}/usr/share/${pkgname}"
  install -Dm 755 ${pkgname} "${pkgdir}/usr/bin/${pkgname}"
}

# vim: ts=2 sw=2 et:
